// Cintia Cristina Palu

function heatMapHexa(value){

	var red;
	var green;
	var blue;
	/*	var sB='FA', sS='C8', nB=250, nS=100, dif=nB-nS;
	var sBv='D9', sSv='64', nBv=200, nSv=50;
	
		var sB='FA', sS='64', nB=250, nS=100, dif=nB-nS;
	var sBv='C8', sSv='32', nBv=200, nSv=50;
*/
	var sB='FA', sS='32', nB=250, nS=50, dif=nB-nS;
	var sBv='C8', sSv='00', nBv=200, nSv=0;
	switch (Math.floor(value)) {
		case 0:
			red=sS;
			green= hexadecimal(nSv+value*dif);
			blue=sB;
			break;
		case 1:
			red=sS;
			green=sBv;
			blue=hexadecimal(nB - dif *(value-1));
			break;
		case 2:
			red=hexadecimal(nS+dif*(value-2));
			green=sBv;
			blue=sS;
			break;
		case 3:
			red=sB;
			green=hexadecimal(nBv-dif*(value-3));
			blue=sS;
			break;
		default:
			
			if (value < 28) {
				red = sB;//hexadecimal(255-((255/12)*(value-4)));
				green = hexadecimal(nSv - (nSv * ((value - 4) / 24)));
				blue = hexadecimal(nS - (nS * ((value - 4) / 24)));
			}
			else {
				if (value > 100) 
					red = hexadecimal(50);//(nB-(nSv+nS));
				else 
					red = hexadecimal(nB - (150 * (value - 28) / 72));//hexadecimal(255-((255/12)*(value-4)));
				green = '00';
				blue = '00';
			}
	}
	
	return ('#' + red + green + blue);
}

function hexadecimal(num){
	var dicker = hexaConvert(parseInt(num / 16));
	var unit = hexaConvert(parseInt(num % 16));
	
	return String(dicker) + String(unit);
}

function hexaConvert(num){
	if (num > 9) {
		switch (num) {
			case 10:
				num = 'A';
				break;
			case 11:
				num = 'B';
				break;
			case 12:
				num = 'C';
				break;
			case 13:
				num = 'D';
				break;
			case 14:
				num = 'E';
				break;
			case 15:
				num = 'F';
				break;			
			case 16:
				
				break;
		}
		
	}
	return num;
}
